package com.yx.pc.api.controller;

import com.yx.common.annotation.Log;
import com.yx.common.utils.R;
import com.yx.pc.api.service.PcTdReadPayLogService;
import com.yx.system.entity.TdReadPayLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 阅读支付记录控制器
 */
@RestController
@RequestMapping("/pc/api/readPayLog")
public class PcTdReadPayLogController {

    @Autowired
    private PcTdReadPayLogService tdReadPayLogService;

    /**
     * 按ID查询阅读支付记录
     *
     * @return
     */
    @Log
    @PostMapping("findByUid")
    public R findByUId(int id) {
        return R.ok().put("user", tdReadPayLogService.selectByPrimaryKey(id));
    }

    /**
     * 新增或修改
     *
     * @return
     */
    @Log
    @PostMapping("saveOrUpdate")
    public R saveOrUpdate(TdReadPayLog tdReadPayLog) {
        if (tdReadPayLog.getId() == 0 || tdReadPayLog.getId() == null) {
            tdReadPayLogService.insert(tdReadPayLog);
        } else {
            tdReadPayLogService.updateByPrimaryKey(tdReadPayLog);
        }
        return R.ok();
    }

    /**
     * 删除 (软删除)
     *
     * @return
     */
    @Log
    @PostMapping("delete")
    public R delete(int id) {
        tdReadPayLogService.deleteByPrimaryKey(id);
        return R.ok();
    }
}
